import random
from prettytable import PrettyTable as PT

def takeSecond(elem):
    return elem[1]

 with open("ips.txt","w+") as file:
     for i in range(120000):
         file.write('172.25.254.'+str(random.randint(1,255))+'\n')

data = open("ips.txt", "r",encoding='utf-8')
list1 = data.readlines()
list2 = []
table = PT(['IP', 'num'])
for i in range(256):
    str1 = '172.25.254.' + str(i) + '\n'
    list2.append(str1)

list3 = []
for temp in list2:
    count = list1.count(temp)
    list3.append([temp, count])

list3 = sorted(list3,key=lambda x:x[1],reverse=True)
for i in range(10):
    table.add_row(list3[i])
# print(list1)
# print(list2)
print(table)

